export Tumor=$1
export Normal=$2
export config_file=$3
export cpu=$4

source ${config_file}


##############################################################
## 定义输出的文件夹

vcf_qc_tmp_path=${vcf_qc_path}/tmp/${Tumor}_${Normal}
mkdir -p ${vcf_qc_tmp_path}

##############################################################
## 缺少的突变
cat ${vcf_path}/${Tumor}_${Normal}_PASS.vcf | grep -v "#" | awk -F'\t' '{OFS=":"}{print $1,$2,$4,$5}' \
> ${vcf_qc_path}/tmp/${Tumor}_${Normal}_lossMut.check.Raw.tsv
cat ${vcf_qc_path}/${Tumor}_${Normal}_MutQc.csv | grep -v POS | awk -F',' '{print $1}' \
> ${vcf_qc_path}/tmp/${Tumor}_${Normal}_lossMut.check.mutqc.tsv

## 提取质控缺少的突变
diff_line=`cat ${vcf_qc_path}/tmp/${Tumor}_${Normal}_lossMut.check.Raw.tsv ${vcf_qc_path}/tmp/${Tumor}_${Normal}_lossMut.check.mutqc.tsv | \
sort | uniq -u`
diff_line_num=`cat ${vcf_qc_path}/tmp/${Tumor}_${Normal}_lossMut.check.Raw.tsv ${vcf_qc_path}/tmp/${Tumor}_${Normal}_lossMut.check.mutqc.tsv | \
sort | uniq -u | wc -l`


##############################################################
## 开始质控
if [ ${diff_line_num} -gt 0 ]
then
echo ${diff_line} | tr ' ' '\n' | xargs -P ${cpu} -i sh -c '
sh ${scripts_path}/GATK4_SomaticVariant_Qc_Step.sh ${Tumor} ${Normal} {} ${config_file} 
' 
else
echo "The line is matched"
fi